﻿@model IEnumerable<SimpleForum.Data.Models.Category>

@{
    ViewBag.Title = "Categories";
}

<div id="content-top">
    <h2>@ViewBag.Title</h2>
    <h3>@Model.Count() @ViewBag.Title</h3>
    <span class="clearfix">&nbsp;</span>
</div>

@if (Model.Count() > 0)
{
    foreach (var Category in Model)
    {
        <div class="box">
            <div class="box-container">
                <div class="category bottom-20" style="width:725px;" id="@Category.Id">
                    <h2 class="bottom-20">@Category.Name</h2>

                    @if(Category.ParentForums.Any()) {
                        foreach (var Forum in Category.ParentForums) {
                            <div class="forum bottom-10" id="@Forum.Id">
                                @{ var NewestThread = Forum.GetNewestThread(); }
                                @if (NewestThread != null) {
                                    <span class="by">latest thread: @Html.ActionLink(NewestThread.Name, "View", "thread", new { id = NewestThread.Id, name = NewestThread.Name.Slugify() }, null) by @Html.DisplayFor(x => NewestThread.Creator, "User.Slim") @Html.DisplayFor(x => NewestThread.CreatedDate)</span>
                                }

                                <div class="counts">
                                    <div class="count"><span class="blue">@Forum.Threads.Count</span><br />threads</div>
                                    <div class="count"><span>@Forum.TotalPosts</span><br />posts</div>
                                </div>

                                <div class="title">@Html.ActionLink(Forum.Name, "View", "forum", new { id = Forum.Id, name = Forum.Name.Slugify() }, null)</div>
                                <div class="description">@Html.Raw(Forum.Description)</div>

                                <span class="clearfix">&nbsp;</span>
                            </div>
                        }
                    }
                    else
                    {
                        @Html.Notification(NotificationHelper.NotificationTypes.Attention, "No forums exist.")
                    }
        </div>

                <span class="clearfix">&nbsp;</span>
            </div>
        </div>
    }
}
else
{
    @Html.Notification(NotificationHelper.NotificationTypes.Attention, "No categories exist.")
}